import request from '@/config/axios'

// 采购订单主 VO
export interface PomainVO {
  id: number // id
  code: string // 流水号
  cpersoncode: string // 业务员编码
  cdepcode: string // 部门编码
  cvencode: string // 供应商编码
  cmemo: string // 备注
  checkBy: number // 审核人
  status:any
}


// 采购订单子表 VO
export interface PomainsVO {
  id: number // id
  pid: number // 
  inventoryId: any // 
  inventoryCode:any
  inventoryName:any
  inventorySpecModel:any
  inventoryUnitName:any
  cbatch: any // 
  cposcode: any // 
  qty: any // 
  irate: any // 
  price:any
  itaxprice:any
  imoney:any
  itax:any
  isum:any
  cbmemo:any
  useQty:any
  inventoryBrand:any

}

// 采购订单主 API
export const PomainApi = {
  // 查询采购订单主分页
  getPomainPage: async (params: any) => {
    return await request.get({ url: `/wms/pomain/page`, params })
  },

    // 查询采购订单
    getPomainList: async (params: any) => {
      return await request.get({ url: `/wms/pomain/list`, params })
    },

  // 查询采购订单主详情
  getPomain: async (id: any) => {
    return await request.get({ url: `/wms/pomain/get?id=` + id })
  },

  // 新增采购订单主
  createPomain: async (data: PomainVO) => {
    return await request.post({ url: `/wms/pomain/create`, data })
  },

  // 修改采购订单主
  updatePomain: async (data: PomainVO) => {
    return await request.put({ url: `/wms/pomain/update`, data })
  },

  // 删除采购订单主
  deletePomain: async (id: number) => {
    return await request.delete({ url: `/wms/pomain/delete?id=` + id })
  },

  // 导出采购订单主 Excel
  exportPomain: async (params) => {
    return await request.download({ url: `/wms/pomain/export-excel`, params })
  },
  //提交
  submit: async (id: number) => {
    return await request.get({ url: `/wms/pomain/startProcess?id=` + id })
  },
// ==================== 子表（采购订单子） ====================

  // 获得采购订单子列表
  getPomainsListByPid: async (pid) => {
    return await request.get({ url: `/wms/pomain/pomains/list-by-pid?pid=` + pid })
  },

  getPomainsOperateList: async (pid) => {
    return await request.get({ url: `/wms/pomain/pomains/operateList?pid=` + pid })
  },

  
  getPomainsOperateListByParams: async (params: any) => {
    return await request.get({ url: `/wms/pomain/pomains/getPomainsOperateListByParams` , params})
  },
  getPomainsById: async (id) => {
    return await request.get({ url: `/wms/pomain/getPomainsById?id=` + id })
  },
}
